package com.xjj.myoa.controller;

import com.xjj.myoa.model.OaBuMen;
import com.xjj.myoa.model.OaUser;
import com.xjj.myoa.service.BuMenService;
import com.xjj.myoa.service.Impl.BuMenServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping(value="buMen")
public class BuMenController {
    @Autowired
    BuMenServiceImpl buMenService;
    @GetMapping (value = "/list")
    public List<OaBuMen> buMenList(){
        List<OaBuMen> oaBUMenList = buMenService.getBuMenListService();
        return oaBUMenList;
    }
    @PostMapping(value="/delete")//这个注解可以映射到post请求方式
    public boolean deleteOaBuMen(String id){
        //调用service层的方法来处理请求逻辑
        boolean result = buMenService.removeBuMenService(Integer.parseInt(id));
        return result;
    }
    @RequestMapping("edit")
    public boolean editOaBuMen(OaBuMen orgBuMen){
        //调用service层的方法来处理请求逻辑
        boolean result = buMenService.editBuMenService(orgBuMen);
        return result;
    }
    @RequestMapping("/new")
    public boolean newOaUser(OaBuMen orgBuMen){
        //调用service层的方法来处理请求逻辑
        boolean result = buMenService.addBuMenService(orgBuMen);
        return result;
    }
}